#!/bin/bash

echo "开始执行脚本"
date

echo "------------------------------------------------- 启动 docker 容器.."
#echo "执行 docker stop all 停止所有 docker 容器"
#docker stop $(docker ps -aq)
#echo "等待 20 秒钟.."
#sleep 20s
#echo "【Kill】输出 docker 运行情况"
#docker ps

#echo "正式启动 docker 容器.."
#/usr/local/bin/docker-compose -f /opt/package/docker-compose/docker-compose-prod.yml up -d
#echo "等待 20 秒钟.."
#sleep 20s
echo "【Start】输出 docker 启动情况"
docker ps


echo "------------------------------------------------- 启动 java 应用"
echo "执行 killall java 停止所有 java 应用"
killall java
echo "等待 30 秒钟.."
sleep 30s
echo "【Kill】输出 java 运行情况"
ps -ef | grep java | grep www

nohup java -jar /opt/www/java/job.jar > /dev/null 2>&1 &
echo "启动 job.jar 后等待 60 秒钟.."
sleep 60s
nohup java -jar /opt/www/java/user.jar > /dev/null 2>&1 &
echo "启动 user.jar 后等待 30 秒钟.."
sleep 60s
nohup java -jar /opt/www/java/system.jar > /dev/null 2>&1 &
echo "启动 system.jar 后等待 60 秒钟.."
sleep 60s
nohup java -jar /opt/www/java/course.jar > /dev/null 2>&1 &
echo "启动 course.jar 后等待 60 秒钟.."
sleep 60s
nohup java -jar /opt/www/java/gateway.jar > /dev/null 2>&1 &
echo "启动 gateway.jar 后等待 60 秒钟.."
sleep 60s
nohup java -jar /opt/www/java/sba.jar > /dev/null 2>&1 &
echo "启动 sba.jar 后等待 10 秒钟.."
sleep 10s
nohup java -Dfile.encoding=UTF-8 -Dspring.config.location=/opt/www/java/kkFileView/application.properties -jar /opt/www/java/kkFileView/kkFileView-4.3.0.jar --KK_FILE_DIR="/root/kkdata" > /root/logs/kkFileView/kkFileView.log 2>&1 &
echo "启动 kkFileView-4.3.0.jar 后等待 10 秒钟.."
sleep 10s
echo "【Start】输出 java 启动情况"
ps -ef | grep java | grep www


echo "------------------------------------------------- 启动 web 应用"
#echo "关闭和停止 pm2 已有进程.."
#pm2 stop all
#pm2 delete all
#echo "等待 60 秒钟.."
#sleep 60s
#echo "【Kill】输出 pm2 运行情况"
#pm2 list

#cd /opt/www/roncoo-education-web/
#pm2 start npm --name roncoo-education-web -- run start
#echo "启动 pm2 后等待 10 秒钟.."
#sleep 10s

#echo "【Start】输出 pm2 启动情况"
pm2 list
date
